package main

import (
	"calc"
	"fmt"

	"git.apache.org/thrift.git/lib/go/thrift"
)

func runClient(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string) error {
	var transport thrift.TTransport
	var err error
	transport, err = thrift.NewTSocket(addr)
	if err != nil {
		fmt.Println("open socket error")
	}
	transport = transportFactory.GetTransport(transport)
	defer transport.Close()
	if err := transport.Open(); err != nil {
		fmt.Println("error open link")
	}
	c := calc.NewCalcClientFactory(transport, protocolFactory)
	fmt.Println(c.Ping())
	return nil
}
